import 'package:flutter/material.dart';
import 'package:fluttertoast/fluttertoast.dart';
import 'package:get/get.dart';

class Prompt {
    static void toast(String msg, {length = Toast.LENGTH_SHORT}) {
        Fluttertoast.showToast(
            msg: msg,
            toastLength: Toast.LENGTH_SHORT,
            gravity: ToastGravity.CENTER,
            timeInSecForIosWeb: 1,
            backgroundColor: Colors.blueGrey,
            textColor: Colors.white,
            fontSize: 16.0
        );
    }

    static Future<void> showMessageDialog(String msg, {String title = "Notice", String confirm = "OK", VoidCallback? onConfirm, bool cancelable = true}) {
        return showDialog<void>(
            context: Get.context!,
            barrierDismissible: false, // user must tap button!
            builder: (BuildContext context) {
                return WillPopScope(onWillPop: () => Future.value(false), child: AlertDialog(
                    title: Text(title),
                    content: SingleChildScrollView(
                        child: ListBody(children: <Widget>[Text(msg)]),
                    ),

                    actions: <Widget>[
                        TextButton(
                            child: Text(confirm),
                            onPressed: () {
                                if (onConfirm != null) onConfirm();
                                Navigator.of(context).pop();
                            },
                        ),
                    ],
                ));
            }
        );
    }

    static void showProgress() {

    }
}